package com.ailesson.order.api;


import com.ailesson.common.reply.R;
import com.ailesson.order.model.reply.OrderConfirmReply;
import com.ailesson.order.model.req.OrderFormReq;
import com.ailesson.order.service.OrderInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "前端订单模块")
@RestController
@RequestMapping("api/order/orderInfo")
public class OrderInfoApiController {

    @Autowired
    private OrderInfoService orderInfoService;

    @Operation(summary = "生成订单")
    @PostMapping("/submitOrder")
    public R submitOrder(@RequestBody OrderFormReq orderFormVo) {
        Long orderId = orderInfoService.submitOrder(orderFormVo);
        return R.success(orderId);
    }

    @Operation(summary = "获取订单信息")
    @GetMapping("/getInfo/{id}")
    public R getInfo(@PathVariable Long id) {
        OrderConfirmReply orderInfo = orderInfoService.getOrderInfoById(id);
        return R.success(orderInfo);
    }
}
